<template>
<div class="app">
  <div>
    <button @click="isShow=!isShow">切换</button>
  </div>

  <transition name="why" mode="out-in" appear>
    <component :is="isShow?Home:About"></component>
  </transition>
</div>
</template>

<script setup>
import About from './pages/About.vue'
import Home from './pages/Home.vue'
import {ref} from 'vue'
const isShow=ref(false)
</script>

<style scoped>
h2{
  display: inline-block;
}

.why-enter-from,
.why-leave-to{
  opacity: 0;
}

.why-enter-to,
.why-leave-from{
  opacity: 1;
}


.why-enter-active{
  animation: whyAnim 2s ease;
  transition: opacity 2s ease;
}

.why-leave-active{
  animation: whyAnim 2s ease reverse;
  transition: opacity 2s ease;
}

@keyframes whyAnim{
  0%{
    transform: scale(0);
    opacity: 0;
  }

  50%{
    transform: scale(1.2);
    opacity: .5;
  }

  100%{
    transform: scale(1);
    opacity: 1;
  }
}

</style>